//
//  JourneyHeaderDetilCollectionViewCell.m
//  Travel_M_Travel
//
//  Created by APPLE10 on 15-3-24.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "JourneyHeaderDetilCollectionViewCell.h"
#import "UIImageView+WebCache.h"

@implementation JourneyHeaderDetilCollectionViewCell



-(void)dealloc
{
    [_headerDetilImage release];
    [_headerDetilLable release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.headerDetilImage = [[UIImageView alloc]init];
        //        _headerDetilImage.backgroundColor= [UIColor redColor];
        _headerDetilImage.clipsToBounds = YES;
        _headerDetilImage.layer.cornerRadius = 5;
        //        _headerDetilImage.image = [UIImage imageNamed:@"jiazai2.png"];
        [self addSubview:_headerDetilImage];
        [_headerDetilImage release];
        
        self.headerDetilLable = [[UILabel alloc]init];
        [_headerDetilImage addSubview:_headerDetilLable];
        _headerDetilLable.textColor = [UIColor whiteColor];
        [_headerDetilLable release];
        
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    _headerDetilImage.frame = self.bounds;
    _headerDetilImage.backgroundColor = [UIColor redColor];
    
    _headerDetilLable.frame = CGRectMake( _headerDetilImage.frame.size.width / 10, _headerDetilImage.frame.size.height * 4 / 5, _headerDetilImage.frame.size.width * 9 / 10, _headerDetilImage.frame.size.height / 5);
    //    _headerDetilLable.backgroundColor = [UIColor redColor];
    
}

- (void)setHeaderData:(JourneyHeaderDataSource *)jourHearderData
{
    if (_headerData != jourHearderData) {
        [_headerData release];
        _headerData = [jourHearderData retain];
    }
    
    NSString *str = self.headerData.cover;
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    //    NSLog(@"%@",str);
    NSURL *url = [NSURL URLWithString:str];
    [_headerDetilImage setImageWithURL:url];
    
    _headerDetilLable.text = self.headerData.name;
    
}
@end
